<?php
/*

[case record fields (so far)]

decedent_lname						Y
decedent_fname						Y
decedent_mname						Y
decedent loc (city, state, zip)		Y, Y, N
decedent_DOB and decedent_DOD		Y, Y
contact_name
FDMS_case_num						Y
FDMS_vitals_id						Y
general_note
case_misc
sale_type							Y
service_type						Y
tribute
fh_id
fd_id
FDMS_fd_id							add/Y
status								Y/translate

case review form:

KS Admin
FH Manager		has tab to assign case to a(nother) FD
FD

 */

class CaseReviewForm extends Zend_Form
{
    private $picture_path = "";
	private $case_info = null;
	
    public function __construct($options=array())
    {
        parent::__construct($options);

        // set form name and POST
        $this->setName('case_form');
        $this->setMethod('post');
        $this->setEnctype('multipart/form-data');

		$this->case_info = $options['case_info'];
		
        // create basic field decorators
        $basicDecorators = array(
            'ViewHelper',
            array('Errors', array('placement'=>'prepend')),
            array(array('labelBr'=>'HtmlTag'), array('tag'=>'br')),
            array('Label', array('placement'=>'prepend')),
            array( array('outerDiv'=>'HtmlTag'), array('tag'=>'div', 'style'=>'margin-top:5px')),
        );

        $this->setDecorators($basicDecorators);
        
        $fname = new Zend_Form_Element_Text('decedent_fname', array('size'=>30, 'label'=>'First Name', 'required'=>false));
        $mname = new Zend_Form_Element_Text('decedent_mname', array('size'=>30, 'label'=>'Middle Name', 'required'=>false));
        $lname = new Zend_Form_Element_Text('decedent_lname', array('size'=>30, 'label'=>'Last Name', 'required'=>false));

        $city = new Zend_Form_Element_Text('decedent_city', array('size'=>30, 'label'=>'City', 'required'=>false));
        $state = new Zend_Form_Element_Text('decedent_state', array('size'=>20, 'label'=>'State', 'required'=>false));
        $zip = new Zend_Form_Element_Text('decedent_zip', array('size'=>10, 'label'=>'Zip', 'required'=>false));

        $contact_name = new Zend_Form_Element_Text('contact_name', array('size'=>30, 'label'=>'Contact Name', 'required'=>false));

        $FDMS_case_num = new Zend_Form_Element_Text('FDMS_case_num', array('size'=>20, 'label'=>'FDMS Case Num', 'required'=>false));
        $FDMS_vitals_id = new Zend_Form_Element_Text('FDMS_vitals_id', array('size'=>20, 'label'=>'FDMS Vitals Id', 'required'=>false));

        $general_note = new Zend_Form_Element_Textarea('general_note', array('rows'=>4, 'cols'=>80, 'label'=>'Notes') );

        $type = new Zend_Form_Element_Text('type', array('size'=>20, 'label'=>'FDMS Case Num', 'required'=>false));
        $tribute = new Zend_Form_Element_Text('tribute', array('size'=>40, 'label'=>'FDMS Case Num', 'required'=>false));

        $fname->setDecorators( $basicDecorators );
        $mname->setDecorators( $basicDecorators );
        $lname->setDecorators( $basicDecorators );
        $city->setDecorators( $basicDecorators );
        $state->setDecorators( $basicDecorators );
        $zip->setDecorators( $basicDecorators );
        $contact_name->setDecorators( $basicDecorators );
        $FDMS_case_num->setDecorators( $basicDecorators );
        $FDMS_vitals_id->setDecorators( $basicDecorators );
        $general_note->setDecorators( $basicDecorators );

        // form's submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Submit');

        $this->addElements(
            array( $fname, $mname, $lname, $city, $state, $zip,
                   $contact_name, $FDMS_case_num, $FDMS_vitals_id,
                   $general_note, $type, $tribute, $submit ) );

    }

    // dirt-simple template engine.
    public function render_with_template( $template_name )
    {
        $template_file_path = APP_DIR."/views/templates/$template_name";
        $template_contents = file_get_contents( $template_file_path );

        // str_replace() keywords, adding errors where needed
        $form_elements = $this->getElements();

		$template_contents = str_replace( "{ACTION}", $this->getAction(), $template_contents );
		
        $template_contents = str_replace( "{FNAME}", $form_elements['decedent_fname'], $template_contents );
        $template_contents = str_replace( "{MNAME}", $form_elements['decedent_mname'], $template_contents );
        $template_contents = str_replace( "{LNAME}", $form_elements['decedent_lname'], $template_contents );
        
        $template_contents = str_replace( "{CITY}", $form_elements['decedent_city'], $template_contents );
        $template_contents = str_replace( "{STATE}", $form_elements['decedent_state'], $template_contents );
        $template_contents = str_replace( "{ZIP}", $form_elements['decedent_zip'], $template_contents );
        
        $template_contents = str_replace( "{CONTACT_NAME}", $form_elements['contact_name'], $template_contents );
        $template_contents = str_replace( "{FDMSCASE}", $form_elements['FDMS_case_num'], $template_contents );
        $template_contents = str_replace( "{FDMSVITALS}", $form_elements['FDMS_vitals_id'], $template_contents );

        $template_contents = str_replace( "{TYPE}", $form_elements['type'], $template_contents );
        $template_contents = str_replace( "{TRIBUTE}", $form_elements['tribute'], $template_contents );

        $template_contents = str_replace( "{NOTE}", $form_elements['general_note'], $template_contents );

        $template_contents = str_replace( "{SUBMIT_BUTTON}", $form_elements['submit'], $template_contents );

        echo $template_contents;
    }
}

?>